package com.wnxy.test;

import com.wnxy.a_work.WorkProducer;
import com.wnxy.b_fanout.FanoutProducer;
import com.wnxy.c_direct.DirectProducer;
import com.wnxy.d_topic.TopicProducer;
import com.wnxy.e_rpc.Client;
import com.wnxy.f_confirm.ConfirmProducer;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class App {

    @Autowired
    private WorkProducer workProducer;
    @Autowired
    private FanoutProducer fanoutProducer;
    @Autowired
    private DirectProducer directProducer;
    @Autowired
    private TopicProducer topicProducer;
    @Autowired
    private Client client;
    @Autowired
    private ConfirmProducer confirmProducer;

    /* 消息模型：1、简单模式、工作队列模式*/
    @Test
    public void simple(){
        workProducer.sendMsg();
    }

    /* 消息模型：2、发布订阅模式 */
    @Test
    public void publish_subcribe(){
        fanoutProducer.sendMsg();
    }

    /* 消息模型：3、Routing路由模式*/
    @Test
    public void routing(){
        //directProducer.sendMsg("exchange-log","log","日志消息");
        directProducer.sendMsg("exchange-log","error1","日志消息");
    }

    /* 消息模型：4、主题模式*/
    @Test
    public void topicProducer(){
        directProducer.sendMsg("exchange-topic","a.orange.a.a","hello");
        directProducer.sendMsg("exchange-topic","lazy.a.a","使用通配符#");
    }

    /* 消息模型：5、rpc*/
    @Test
    public void rpc(){
        client.sendMsg();
    }

    /* 消息模型：6、消息确认 */
    @Test
    public void confirm(){
        for (int i = 0; i < 5; i++) {
        confirmProducer.sendMsg();

        }
    }

}
